import org.apache.commons.validator.routines.UrlValidator;

import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URL;
import static java.lang.System.*;
/**
 * @author avhaliullin
 */
public class Test {
    public static void main(String[] args) {
        UrlValidator validator = new UrlValidator();
        out.println(validator.isValid("http://ru.wikipedia.travel/wiki/%D0%9E%D0%B1%D1%81%D1%83%D0%B6%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5:%D0%A2%D0%B0%D1%80%D0%B0%D1%81_%D0%91%D1%83%D0%BB%D1%8C%D0%B1%D0%B0_(%D1%84%D0%B8%D0%BB%D1%8C%D0%BC)"));
        try {
            URL url = new URL("http://ru.wikipedia.travel/wiki/%D0%9E%D0%B1%D1%81%D1%83%D0%B6%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5:%D0%A2%D0%B0%D1%80%D0%B0%D1%81_%D0%91%D1%83%D0%BB%D1%8C%D0%B1%D0%B0_(%D1%84%D0%B8%D0%BB%D1%8C%D0%BC)");

            try {
                out.println(url.toURI().toASCIIString());
            } catch (URISyntaxException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}
